package chapter1;

public class SelectSort {
    public static void selectionSort(int[] arr){
        if (arr == null || arr.length <2){
            return;
        }
        for (int i = 0; i < arr.length -1; i++) {
            int min_index = i;
            for (int j = i; j < arr.length; j++) {
                min_index = arr[j]<i?arr[j]:i;
            }
            swap(arr,i,min_index);
        }
    }
    public static void swap(int[] arr,int i,int j){
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }


    public static void main(String[] args) {

    }
}
